package com.share.lagou.decoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.CharsetUtil;

/**
 * @author caifan
 * @since 2022/7/19
 */
public class RequestSampleHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        final String data = ((ByteBuf) msg).toString(CharsetUtil.UTF_8);
        final ResponseSample responseSample = new ResponseSample("OK", data, System.currentTimeMillis());
        // 出站操作
        ctx.channel().writeAndFlush(responseSample);
    }
}
